package com.yadang.admin.service.impl;

import com.yadang.admin.entity.LitemallAd;
import com.yadang.admin.entity.LitemallRole;
import com.yadang.admin.mapper.LitemallAdMapper;
import com.yadang.admin.mapper.LitemallRoleMapper;
import com.yadang.admin.service.ILitemallAdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 广告表 服务实现类
 * </p>
 *
 * @author astupidcoder
 * @since 2021-06-19
 */
@Service
public class LitemallAdServiceImpl extends ServiceImpl<LitemallAdMapper, LitemallAd> implements ILitemallAdService {


    @Autowired
    private LitemallAdMapper mapper;

    @Autowired
    private LitemallRoleMapper roleMapper;

    public LitemallAdMapper getMapper(){
        return this.mapper;
    }

    @Override
    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED)
    public void addLitemallAd() {
        // 添加Ad
        LitemallAd litemallAd = new LitemallAd();
        litemallAd.setId(10002);
        litemallAd.setName("测试");
        litemallAd.setLink("http://juejin.com");
        litemallAd.setUrl("sdfs");
        mapper.insert(litemallAd);
        roleMapper.insert(new LitemallRole().setId(11102).setName("测试"));
        //addRole();
    }

    public void addRole(){
        roleMapper.insert(new LitemallRole().setId(11102).setName("测试"));
    }
}
